import Axios from "../utils/axios";
import api from "../api/index";

//商品分类列表请求      
function classList() {
  return Axios.get(api.productClassify.categories);
}
//根据id删除
function deleteById(id:any){
  return Axios.delete(api.productClassify.categories_+id)
}
//根据id获取
function getById(id:any){
  return Axios.get(api.productClassify.categories_+id)
}
//添加新类型
function addNew(form:any){
  return Axios.post(api.productClassify.categories,form)
}
//更新
function update(form:any){
  return Axios.put(api.productClassify.categories_+form.id,form)
}
//获取类型结构
function cascade(){
  return Axios.get(api.productClassify.cascade);
}
//批量添加属性
function batch(cateId:any,type:any,data:any){
  return Axios.post(api.productClassify.batch,{categoryId:cateId,type:type,attributes:data})
}
//获取属性列表
function attributes(cateId:any,type:any){
  return Axios.get(api.productClassify.attributes,{params:{categoryId:cateId,type:type}})
}

export default {
  classList,
  deleteById,
  getById,
  addNew,
  cascade,
  update,
  batch,
  attributes,
};
